package tests;

import gameTheory.MixedProfileGenerator;
import gameTheory.PayoffMatrix;
import gameTheory.ProfileGenerator;
import gameTheory.PureProfileGenerator;
import gameTheory.PayoffMatrix.Position;
import graphs.Graph;
import graphs.TwoRouteSameSpeedGraph;

public class FourRoadMixedStrategyTest {

	public static void main(String[] args) {
		long beginTime = System.currentTimeMillis();
		//Graph g = new TwoRouteGraph();
		Graph g = new TwoRouteSameSpeedGraph();
		ProfileGenerator gen = new MixedProfileGenerator(g);
		PayoffMatrix matrix = new PayoffMatrix(gen, g);
		System.out.println("Player Strategy's");
		System.out.println(toString(matrix.getPlayerStrategy()));
		System.out.println("Others strategy's");
		System.out.println(toString(matrix.getOtherStrategy()));
		System.out.println("");
		//System.out.println("Matrix:");
		//System.out.println(matrix);
		System.out.println("Equilibria ("+matrix.getEquilibria().size()+"):");
		//System.out.println(matrix.getEquilibria());
		for(Position p:matrix.getEquilibria()){
			System.out.println("Player:"+matrix.getPlayerStrategyByIndex(p.x)+" Other:"+matrix.getOtherStrategyByIndex(p.y));
		}
		System.out.println("");
		System.out.println("duration:" + (System.currentTimeMillis() - beginTime));
		System.out.println("done");
	}
	
	public static String toString(Object[] array){
		StringBuilder b = new StringBuilder();
		for(int i = 0 ; i < array.length ; i++){
			b.append(array[i].toString());
			b.append(", ");
		}
		int komma = b.lastIndexOf(", ");
		b.delete(komma,komma+1);
		return b.toString();
	}
}
